home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-04-08 | 5.2 KB | 145 lines | [TEXT/CCL2] |
- #|
- mini-app-example.lisp
-
- An example of how the Mini-Application core technology can be
- used to build a simple application.
-
- To run the Mini-Application, see "build-and-run-mini-app.lisp".
-
- This file is loaded on top of the Mini-Application core technology
- upon which it defines the items to be instantiated in the tool
- palette (their class, name, and visible representation), and their
- behavior when they are selected. The core technology already knows
- about draw-items.
-
- For further info, see files "About Mini-App" and "Instructions".
-
-
- Copyright 1990, 1991 by Ruben Kleiman for Apple Computer, Inc.
- Acknowledgements: Thanks to Dave Vronay for some pieces of code.
-
- Change History.
- 03-11-92 slm Changed all occurrences of defvar to defparameter (8)
- so that after the Mini-Application is modified, the
- changed files can be re-evaluated immediately.
- 03-09-92 slm Updated file header comments.
- 03-07-92 slm Adapted from superseded file "example.lisp".
-
- |#
-
- ;;; ________________________________________________________________________________________
- ;;; SOME DRAW-ITEM PROTOTYPES
- ;;;
-
- ;;; We create a round button, a check box, a radio button, a text field, a
- ;;; QuickDraw rectangle and oval. We will put them up on a palette.
- ;;;
-
- (defparameter *round-button* (create-draw-item :name "Round Button"
- :class 'round-button))
-
- (defparameter *check-box* (create-draw-item :name "Check Box"
- :class 'check-box))
-
- (defparameter *radio-button* (create-draw-item :name "Radio Button"
- :class 'radio-button))
-
- (defparameter *text* (create-draw-item :name "Text"
- :class 'text))
-
- (defparameter *rectangle* (create-draw-item :name "Rectangle"
- :class 'rectangle))
-
- (defparameter *oval* (create-draw-item :name "Oval"
- :class 'oval))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; mouse-down [draw-item]
- ;;;
- ;;; Here, we over-ride the default mouse-down method for draw-item
- ;;; to set the global *clonable-item* to the name of the class
- ;;; of the draw-item which has been selected. This will let the
- ;;; windows know which object to create on a window when the user
- ;;; uses the select rectangle style.
- ;;;
- (defmethod mouse-down ((me draw-item) where)
- (declare (ignore where))
- (setq *clonable-item* me))
-
-
- ;;; ________________________________________________________________________________________
- ;;; SOME TOOL PROTOTYPES
- ;;;
-
- ;;; We create three icons that will stand for palette tools.
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; *browse-tool*
- ;;;
- ;;; This tool will be used to set windows into browse mode.
- ;;;
- (defclass browser-tool (icon-draw-item)
- ()
- )
-
- (defparameter *browse-tool* (create-tool :name "Browse"
- :class 'browser-tool
- :resource-id 102))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; mouse-down [browser-tool]
- ;;;
- ;;; This mouse-down handler will switch the author/browse mode
- ;;; of all draw-dialog windows and put a dialog box
- ;;; showing what mode we are now in.
- ;;;
- (defmethod mouse-down ((browser browser-tool) where)
- (declare (ignore where))
- (setq *clonable-item* nil) ; Disable creation via rectangle selection
- (let ((browse-mode nil)) ; Peek at current browse mode
- (dolist (window (windows :class 'draw-dialog))
- (and (neq (type-of window) 'PALETTE)
- (setq browse-mode
- (setf (slot-value window 'browse-mode)
- (not (slot-value window 'browse-mode))))))
- ;(ed-beep)
- (message-dialog (format
- nil
- "~%All drawing windows are now in ~:[author~;browse~] mode"
- browse-mode))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; *quit-tool*
- ;;;
- ;;; This tool can be used to quit the mini-application.
- ;;;
- (defclass quit-tool (icon-draw-item)
- ()
- )
-
- (defparameter *quit-tool* (create-tool :name "Quit"
- :class 'quit-tool
- :resource-id 103))
-
- (defmethod mouse-down ((me quit-tool) where)
- (declare (ignore where))
- (when (y-or-n-dialog "Are you sure you want to Quit our wonderful application?")
- (quit))) ;Quits MCL too
-
- ;;; ________________________________________________________________________________________
- ;;; LIST OF AVAILABLE TOOL AND DRAW-ITEM PROTOTYPES
- ;;;
-
- (setq *available-tools* (list *browse-tool*
- *quit-tool*))
-
- (setq *available-draw-items* (list *round-button*
- *radio-button*
- *check-box*
- *text*
- *oval*
- *rectangle*))
-
- ;end of file mini-app-example.lisp
- ;------------------------------------------------
-